#include "iostream"
#include <cstdlib>
#include <cstdio>

using namespace std;

//1 new delete 操作符号 c++的关键字
//malloc free函数

//2 new 在堆上分配内存  delete 
//分配基础类型 、分配数组类型、分配对象




class Test
{
public:
	Test(int mya, int myb)
	{
		a = mya;
		b = myb;
		cout<<"构造函数，我被调用了"<<endl;
	}
	~Test()
	{
		//
		cout<<"析构函数，我被调用了"<<endl;
	}
	int getA()
	{
		return a;
	}
protected:
private:
	int a;
	int b;
};



int main()
{

	{
		
		Test *p3 = new Test(1,2);
		free(p3);//free method will not invoke destruction method

	}

	cout << "===============================" << endl;

	{
		//malloc不会调用这个类的构造函数
		Test*p3 = (Test *)malloc(sizeof(Test)); 
		delete p3;
	}


	return 0;

}